package com.taotao.portal.web;

import com.taotao.portal.pojo.TbItemExt;
import com.taotao.portal.service.TbItemDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TbItemDetailsController {

    @Autowired
    private TbItemDetailsService tbItemDetailsService;

    @RequestMapping("/item/{id}")
    public String toItemDetailsPage(@PathVariable("id") Long id, Model model){
        TbItemExt tbItemExt = tbItemDetailsService.getTbItemInfo(id);
        model.addAttribute("item", tbItemExt);
        return "item";
    }

    @RequestMapping("/item/desc/{id}")
    @ResponseBody
    public String getTbItemDesc(@PathVariable Long id) {
        String html = tbItemDetailsService.getTbItemDesc(id);
        return html;
    }

    @RequestMapping("/item/param/{id}")
    @ResponseBody
    public String getItemParam(@PathVariable Long id) {
        String html = tbItemDetailsService.getItemParam(id);
        return html;
    }


}
